package org.yu.api.register;

import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.Block;
import org.jetbrains.annotations.Nullable;

import java.util.function.Supplier;

public record BlockHolder<T extends Block>(
        @Nullable ItemHolder<? extends Item> itemHolder,
        Supplier<T> block) implements Supplier<T>,ItemLike {

    @Override
    public T get() {
        return block.get();
    }

    @Override
    public Item asItem() {
        if (itemHolder!=null)
        return itemHolder.asItem();
        return Items.AIR;
    }
}
